/**
 * 
 */
package org.braketester.view;

import java.awt.BorderLayout;

import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 * @author LAP
 *
 */
public class ChartView extends JPanel {
	private static final long serialVersionUID = 1L;
	
	private JFreeChart contentCeeper;
	private XYSeriesCollection dataset;
	
	public ChartView() {
		setLayout(new BorderLayout());
		createContent();
	}
	
	private void createContent() {
		dataset = new XYSeriesCollection();
		contentCeeper = ChartFactory.createXYLineChart(
				null, 
				null, 
				null, 
				dataset, 
				PlotOrientation.HORIZONTAL, 
				false, 
				false, 
				false);
		ChartPanel panel = new ChartPanel(contentCeeper);
		add(panel, BorderLayout.CENTER);
	}
	
	public void addXYSeries(XYSeries series) {
		dataset.addSeries(series);
	}
	
	public void setTitle(String title) {
		contentCeeper.setTitle(title);
	}
}
